package chapter10;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2019/4/13 13:31
 */
public class Parcel10 {
    public static void main(String[] args) {
        Parcel10 parcel10 = new Parcel10();
        Destination destination = parcel10.destination("Tasmania", 101.2343F);
        destination.readLabel();
    }

    public Destination destination(final String dest, final float price) {
        return new Destination() {
            private int cost;
            private String label = dest;

            {
                cost = Math.round(price);
                if (cost > 100) {
                    System.out.println("over budget");
                }
            }

            @Override
            public String readLabel() {
                System.out.println("label:" + label);
                return label;
            }
        };
    }
}
